<?php
class start extends controller{
	public $projects;

	public function __construct($url){
		parent::__construct($url, true);
		$this->projects = null;
	}
	
	public function check(){}

	public function run(){
		$this->getProjects();
	}

	private function getProjects(){
		$sql = "SELECT project.name, project.descr, user.name, project.status, project.id, project.link FROM project, user";
		switch($_SESSION["user"][5]){
			case 1:
				$sql .= " WHERE project.customer=user.id AND project.customer=".$_SESSION["user"][0];
				break;
			case 2:
				$sql .= ", developer WHERE project.customer=user.id AND project.id=developer.project_id AND developer.developer=".$_SESSION["user"][0];
				break;
			case 3:
				$sql .= " WHERE project.customer=user.id";
				break;
		}
		$sql .= " ORDER BY status, id DESC";
		$this->projects = $this->database->fetchRow($sql);
	}
}
?>
